package de.hs_fulda.SoftComputing.Gogol.Wasserkraft;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.io.File;
import java.io.FileReader;

import javax.swing.JPanel;

public class WasserkraftUIPane extends JPanel {
  private static final long serialVersionUID = 1L;
  private Image img = null;

  WasserkraftUIPane(String imagefile) {
    super(new BorderLayout());
    setPreferredSize(new Dimension(800, 600));
    File file = new File(imagefile);
    
    // Background Picture
    if (file.canRead()) {
      MediaTracker mt = new MediaTracker(this);
      img = Toolkit.getDefaultToolkit().getImage(imagefile);
      mt.addImage(img, 0);
      try {
	mt.waitForAll();
      } catch (InterruptedException e) {
	e.printStackTrace();
      }
    } else {
      System.err.println("could not open Background Image:" + imagefile);
    }
  }

  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (img != null)
      g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
  }

}
